/**
 * 角色路由
 * 定义角色相关的API路由
 */
import { Router } from "express";
import RoleController from '../controllers/role.controller.js';
import {
  createRoleValidator,
  updateRoleValidator,
  roleIdValidator,
  roleListValidator,
  assignMenusValidator
} from '../validators/role.validator.js';

const router = Router();

// 创建角色
router.post('/', createRoleValidator, RoleController.createRole);

// 更新角色
router.put('/:id', updateRoleValidator, RoleController.updateRole);

// 删除角色
router.delete('/:id', roleIdValidator, RoleController.deleteRole);

// 获取角色列表
router.get('/page', roleListValidator, RoleController.getRoleList);

// 获取角色详情
router.get('/:id', roleIdValidator, RoleController.getRoleDetail);

// 为角色分配菜单
router.post('/menus/:id', assignMenusValidator, RoleController.assignRoleMenus);

// 获取角色菜单树
router.get('/menu-tree/:id', roleIdValidator, RoleController.getRoleMenuTree);

export default router; 